<?php

namespace YmPhp\Admin\Http\Forms;

use YmPhp\Admin\Models\Setting as SystemSettingModel;
use YmPhp\Admin\Widgets\Form;

class SystemSettingSiteCityConfigForm extends Form
{
    /**
     * The form title.
     *
     * @var string
     */
    public $title = '基本设置';


    /**
     * Handle the form request.
     *
     * @param Request $request
     *
     */
    public function handle(array $input)
    {
        (new SystemSettingModel())->saveConfig($input, 'system_city_config');
        return $this->response()->success('保存成功')->refresh();
    }

    /**
     * Build a form here.
     */
    public function form()
    {
        $this->tab(trans('site-city.titles.site_setting'), function () {
            $this->url('siteurl', trans('site-city.titles.siteurl'))->help(trans('site-city.titles.siteurl_msg'))->width(6);
            $this->radio('show_substation', trans('site-city.titles.show_substation'))->options(['0' => trans('setting.basic.close'), '1' => trans('setting.basic.open')])->help(trans('site-city.titles.show_substation_msg'));
            $this->radio('show_substation_business', trans('site-city.titles.show_substation_business'))->options(['0' => trans('setting.basic.close'), '1' => trans('setting.basic.open')])->help(trans('site-city.titles.show_substation_business_msg'));
            $this->radio('show_total_city_count', trans('site-city.titles.show_total_city_count'))->options(['0' => trans('setting.basic.close'), '1' => trans('setting.basic.open')])->help(trans('site-city.titles.show_total_city_count_msg'));
            $this->radio('show_divide_city_count', trans('site-city.titles.show_divide_city_count'))->options(['0' => trans('setting.basic.close'), '1' => trans('setting.basic.open')])->help(trans('site-city.titles.show_divide_city_count_msg'));
            $this->radio('show_divide_city_choose', trans('site-city.titles.show_divide_city_choose'))->options(['0' => trans('setting.basic.close'), '1' => trans('setting.basic.open')])->help(trans('site-city.titles.show_divide_city_choose_msg'));
            $this->text('city_name', trans('site-city.titles.city_name'))->width(3);
            $this->text('city_ad_num', trans('site-city.titles.city_ad_num'))->width(3);
            $this->text('location_remind', trans('site-city.titles.location_remind'))->help(trans('site-city.titles.location_remind_msg'))->width(3);
            $this->radio('is_location', trans('site-city.titles.is_location'))->options(['0' => trans('setting.basic.close'), '1' => trans('setting.basic.open')])->help(trans('site-city.titles.is_location_msg'));
            $this->radio('divide_city_total_count', trans('site-city.titles.divide_city_total_count'))->options(['0' => trans('setting.basic.close'), '1' => trans('setting.basic.open')])->help(trans('site-city.titles.divide_city_total_count_msg'));
            $this->radio('area_city_auto', trans('site-city.titles.area_city_auto'))->options(['0' => trans('setting.basic.close'), '1' => trans('setting.basic.open')])->help(trans('site-city.titles.area_city_auto_msg'));
            $this->radio('city_category', trans('site-city.titles.city_category'))->options(['0' => trans('setting.basic.close'), '1' => trans('setting.basic.open')])->help(trans('site-city.titles.city_category_msg'));
            $this->text('city_screen_name', trans('site-city.titles.city_screen_name'))->width(3);
            $this->radio('show_divide_city_area', trans('site-city.titles.show_divide_city_area'))->options(['0' => trans('setting.basic.close'), '1' => trans('setting.basic.open')])->help(trans('site-city.titles.show_divide_city_area_msg'));
            $this->radio('total_city_name', trans('site-city.titles.total_city_name'))->options(['0' => trans('setting.basic.close'), '1' => trans('setting.basic.open')])->help(trans('site-city.titles.total_city_name_msg'));
            $this->text('city_memory_long', trans('site-city.titles.city_memory_long'))->help(trans('site-city.titles.city_memory_long_msg'))->width(3);
            $this->radio('city_induce_type', trans('site-city.titles.city_induce_type'))->options(['1' => trans('site-city.titles.city_induce_type_1'), '2' => trans('site-city.titles.city_induce_type_2'), '3' => trans('site-city.titles.city_induce_type_3')]);
            $this->text('city_initial_fee', trans('site-city.titles.city_initial_fee'))->width(3);
            $this->text('city_initial_time', trans('site-city.titles.city_initial_time'))->help(trans('site-city.titles.location_remind_msg'))->width(3);
            $this->radio('hide_apply', trans('site-city.titles.hide_apply'))->options(['0' => trans('setting.basic.close'), '1' => trans('setting.basic.open')])->help(trans('site-city.titles.location_remind_msg'));

            $this->textarea('default_keywords', trans('site-city.titles.default_keywords'))->width(3);


        });

    }

    /**
     * The data of the form.
     *
     * @return array $data
     */
    public function data()
    {
        $datas = SystemSettingModel::pluck('value', 'key');
        return $datas['system_city_config'];
    }


}



